//
//  SXTMyViewController.m
//  SYT
//
//  Created by 彭之耀 on 2017/8/23.
//  Copyright © 2017年 个人学习. All rights reserved.
//

#import "SXTMyViewController.h"
#import "SXTMyPageHeadView.h"
#import "SXTMyPageTableView.h"
#import "SXTRegisterViewController.h"

@interface SXTMyViewController ()

@property(strong,nonatomic) SXTMyPageHeadView *headView;           //顶部view

@property(strong,nonatomic) SXTMyPageTableView *messageTable;

@end

@implementation SXTMyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.edgesForExtendedLayout = 0;
    self.view.backgroundColor = MainColor;
    [self.view addSubview:self.headView];
    [self.view addSubview:self.messageTable];
    [self addLayoutSubView];
}

-(void)addLayoutSubView{
    __weak typeof (self) weakSelf = self;
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(weakSelf.view);
        make.height.mas_equalTo(150);
    }];
    
    [_messageTable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(weakSelf.view);
        make.height.mas_equalTo(176);
        make.top.equalTo(weakSelf.headView.mas_bottom).offset(35);
    }];
}

-(SXTMyPageHeadView *)headView{
    if (_headView == nil) {
        _headView = [[SXTMyPageHeadView alloc]init];
        __weak typeof (self) weakSelf = self;
        _headView.landingBlock = ^(){
            SXTRegisterViewController *loginViewController = [[SXTRegisterViewController alloc]init];
            [weakSelf.navigationController pushViewController:loginViewController animated:YES];
        };
    }
    return _headView;
}

-(SXTMyPageTableView *)messageTable{
    if (!_messageTable) {
        _messageTable = [[SXTMyPageTableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
        _messageTable.backgroundColor = [UIColor redColor];
        _messageTable.bounces = NO;
    }
    return _messageTable;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
